package 易立德.不含重复字符的最长子串;

import java.util.TreeSet;

public class Main {

    public  int result(String str){
        char[] chars = str.toCharArray();
        TreeSet<Character> set = new TreeSet<>();
        int max=0;
        if (str.length()==0){
            return max;
        }
        for (int i = 0; i < chars.length; i++) {
            boolean add = set.add(chars[i]);
            if (!add){
                max=max==0?set.size():Math.max(max,set.size());
                set.clear();
                set.add(chars[i]);
            }
        }

        return Math.max(set.size(),max);
    }
}
